package org.zfes.snowier.zbss.xzy.router.behaviour;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.behaviour.model.BehaviourType;
import org.zfes.snowier.zbss.xzy.biz.behaviour.service.IBehaviourTypeService;
import org.zfes.snowier.core.data.SelectVo;
@Controller 
@RequestMapping("/behaviour")
public class BehaviourTypeController implements BaseController {

	
	@Autowired
	private IBehaviourTypeService behaviourTypeService;
	
	//@RequiresPermissions(value="behaviourType:loadBehaviourTypeDataSet",desc="行文类型列表")
    @RequestMapping(value="/loadBehaviourTypeDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadBehaviourTypeDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  behaviourTypeService.loadBehaviourTypeDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="behaviourType:createBehaviourType",desc="行文类型添加")
    @RequestMapping(value="/createBehaviourType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createBehaviourType(@RequestBody BehaviourType behaviourType){
		behaviourTypeService.createBehaviourType(behaviourType);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="behaviourType:loadBehaviourType",desc="行文类型加载")
    @RequestMapping(value="/loadBehaviourType/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadBehaviourType(@PathVariable("id")Long id){
		Optional<BehaviourType> ops = behaviourTypeService.loadBehaviourTypeById(id);
		return ajaxQuery("behaviourType",ops);
    }
	
	//@RequiresPermissions(value="behaviourType:updateBehaviourType",desc="行文类型更新")
    @RequestMapping(value="/updateBehaviourType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateBehaviourType(@RequestBody  BehaviourType behaviourType){
		behaviourTypeService.updateBehaviourType(behaviourType);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="behaviourType:deletBehaviourType",desc="行文类型删除")
    @RequestMapping(value="/deleteBehaviourType/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteBehaviourType(@PathVariable("id")Long id){
		behaviourTypeService.deleteBehaviourType(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadBehaviourTypeSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadBehaviourTypeSelectVo(){
		 List<SelectVo>  ops = behaviourTypeService.loadBehaviourTypeSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}